<%@ page import="java.util.Map" %>
<%@ page import="com.hrm.entity.EmployeeEntity" %>
<%@ page import="com.hrm.dto.Envelope" %>
<%@ page import="java.util.List" %>
<%@ page import="com.hrm.entity.PosEntity" %><%--
  Created by IntelliJ IDEA.
  User: zekdot
  Date: 20-3-11
  Time: 下午9:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%
        Map<String,Object> map = (Map<String, Object>) request.getAttribute("param");
        EmployeeEntity employeeEntity = (EmployeeEntity) ((Envelope) map.get("employee")).getObj();
        List<String> posEntityList = (List<String>) ((Envelope) map.get("positions")).getObj();
    %>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <link href="${pageContext.request.contextPath}/css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="div_form">
    <h1 class="h1_style"><i class="i_h1"></i> 职位调动</h1>
        <p class="form_p"><label class="form_label">员工编号：</label>
            <input type="text" class="form_input readonly" readonly="readonly" value="<%=employeeEntity.getId()%>">
        </p>
    <p class="form_p"><label class="form_label">职位：</label>
            <%
            if(employeeEntity.getStatus() == 0){
            %>
            <select id="pos" class="form_input1">
                <%
                    for(String pos:posEntityList){
                %>
                <option <%=pos.equals(employeeEntity.getPosition())?"selected":""%>><%=pos%></option>
                <%
                    }
                %>
            </select>
            <%
            }else{
            %>
        <input type="text" class="form_input readonly" readonly="readonly"
               value="<%=employeeEntity.getPosition()%>">
            <%
            }
            %>
    </p>
    <%
        if(employeeEntity.getStatus() == 0){
    %>
        <p class="but_p">
            <input type="button" id="save" value="调动" class="but_save"/>
            <button id="leave" class="but_save">离职</button>
        </p>
    <%
        }
    %>
    <p class="but_p">

        <button class="but_save" onclick="location.href='${pageContext.request.contextPath}/employee/editSalaryPage?id=<%=employeeEntity.getId()%>'">薪水管理</button>

        <button class="but_save" onclick="location.href='${pageContext.request.contextPath}/employee/editInfoPage?id=<%=employeeEntity.getId()%>'">档案管理</button>

    </p>
</div>
    <script>
        $('#save').click(function () {
            if(!confirm('您确定让该员工调动到新职位吗？')){
                return;
            }
            var data = {'id':'<%=employeeEntity.getId()%>','newDep':'<%=employeeEntity.getDepartment()%>',
                'newPos':$('#pos').val()};
            $.post('transfer',data,function(str){
                var res = eval('(' + str + ')');
                if(res.code != 0){
                    alert(res.message);
                    return;
                }
                location.href = location.href;
            });
        });
        $('#leave').click(function () {
            if(!confirm('您确定让该员工离职吗？')){
                return;
            }
            var data = {'id':'<%=employeeEntity.getId()%>'};
            $.post('leave',data,function(str){
                var res = eval('(' + str + ')');
                if(res.code != 0){
                    alert(res.message);
                    return;
                }
                location.href = location.href;
            });
        });
    </script>
</body>
</html>
